//获得商品列表的父容器
var mainEle = document.querySelector(".main");
//只要触发了点击事件，就会捕捉点击的对象
mainEle.onclick = function (event) {
    var ele = event.target;

    var choiceInfo = document.querySelector("#choice");
    choiceInfo.innerText = "";
    if (ele.nodeName == 'A') {
        var lis = ele.parentElement.parentElement.children;
        for (var i = 0; i < lis.length; i++) {
            lis[i].firstElementChild.className = "";
        }
        ele.setAttribute('class', 'pitch')
    }
    var as = document.querySelectorAll(".pitch");
    for (var j = 0; j < as.length; j++) {
        console.log(choiceInfo.innerText);
        if (as[j].innerText != "所有") {
            if (choiceInfo.innerText == "") {
                choiceInfo.innerText = as[j].innerText;
            } else {
                choiceInfo.innerText += "+" + as[j].innerText;
            }
        }
    }
}

layui.use(['laypage', 'layer'], function () {
    var laypage = layui.laypage
        , layer = layui.layer;

    //总页数大于页码总数
    laypage.render({
        elem: 'demo1',
        theme:"#00d7c6",
        count: 70, //数据总数
        jump: function (obj) {
            console.log(obj)
        }
    });
});


//全选按钮
var selectAllEle=document.querySelector(".select-all");
/*console.log(selectAllEle);*/

selectAllEle.onclick=function() {
    var ckboxes = document.querySelectorAll(".yl input[type=checkbox]");
//    console.log(ckboxes);
  /*  console.log(selectAllEle.checked);*/
    for (var i = 0; i < ckboxes.length; i++) {
        ckboxes[i].checked = selectAllEle.checked
    }
}
